package com.andaily.domain.account.actions;

import com.andaily.domain.account.AccountRepository;
import com.andaily.domain.dto.account.AccountMonthChartDto;
import com.andaily.domain.shared.security.SecurityUtils;
import com.andaily.infrastructure.mybatis.data.AccountStatisticsData;
import com.andaily.web.context.BeanProvider;

import java.util.List;

/**
 * Date: 13-7-31
 *
 * @author Shengzhao Li
 */
public class AccountMonthChartDtoLoader {

    private transient AccountRepository accountRepository = BeanProvider.getBean(AccountRepository.class);

    public AccountMonthChartDtoLoader() {
    }

    public AccountMonthChartDto load() {
        final String userGuid = SecurityUtils.currentUserGuid();
        AccountMonthChartDto accountMonthChartDto = new AccountMonthChartDto();
        List<AccountStatisticsData> dataList = accountRepository.findMonthChartData(userGuid, accountMonthChartDto.getChartDataSize());

        return accountMonthChartDto.updateList(dataList);
    }
}
